﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Compilation;
using System.Security.Permissions;
using System.Xml;

namespace RBTools.CodeGenerator.BuildProviders
{
    [PermissionSet(SecurityAction.Demand, Unrestricted = true)]
    public class MessageBuildProvider : BuildProvider
    {
        public override void GenerateCode(AssemblyBuilder assemblyBuilder)
        {
            MessageCodeGenerator codeGenerator = new MessageCodeGenerator();
            XmlDocument xmlDoc = new XmlDocument();

            using (var stream = base.OpenStream())
            {
                xmlDoc.Load(stream);
            }

            assemblyBuilder.AddCodeCompileUnit(this,codeGenerator.BuildCodeCompileUnit(xmlDoc));
        }

        public override CompilerType CodeCompilerType
        {
            get
            {
                return GetDefaultCompilerTypeForLanguage("CSharp");
            }
        }
         
    }
}
